//
//  FPSubmitOrderVC.m
//  ForestPack
//
//  Created by jimmy on 2018/7/18.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "FPSubmitOrderVC.h"
#import "SubmitOrderCell.h"
#import "FPCommodityDetailVC.h"
#import "SearchRecordViewController.h"

@interface FPSubmitOrderVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)  BaseTableView  * tableView;

@end

@implementation FPSubmitOrderVC

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self setTitle:@"提交订单"];
    [self setTableViewUI];
    
}

-(void)setTableViewUI
{
    self.tableView = [[BaseTableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT)];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    [self.view addSubview:self.tableView];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return ScreenX375(252);
    }else{
        return ScreenX375(680);
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 10;
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] init];
    return view;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        SubmitOrderSuccessCell *cell = [SubmitOrderSuccessCell cellWithTable:tableView withIndexPath:indexPath];
        return cell;
    }else{
        SubmitOrderCell *cell = [SubmitOrderCell cellWithTable:tableView withIndexPath:indexPath];
        cell.moreCommodityClick = ^{
            SearchRecordViewController *searchRecordVC = [[SearchRecordViewController alloc] init];
            [self.navigationController pushViewController:searchRecordVC animated:true];
        };
        cell.commodityDetailClick = ^{
            FPCommodityDetailVC *vc = [[FPCommodityDetailVC alloc] init];
            [self.navigationController pushViewController:vc animated:true];
        };
        return cell;
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:false];
}


@end
